package acwing;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing.QuestionsPractice
 * @File : Q4945.java
 * @Author : WangRuoyu
 * @Date : 2023/4/1 19:03
 */

import java.io.*;

public class Q4945 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] words = br.readLine().split(" ");
        int n = Integer.parseInt(words[0]);
        int bx = Integer.parseInt(words[1]);
        words = br.readLine().split(" ");
        long x = 0;
        for (int i = 0; i < n; ++i) {
            int k = Integer.parseInt(words[i]);
            x = x * bx + k;
        }

        words = br.readLine().split(" ");
        int m = Integer.parseInt(words[0]);
        int by = Integer.parseInt(words[1]);
        words = br.readLine().split(" ");
        long y = 0;
        for (int i = 0; i < m; ++i) {
            int k = Integer.parseInt(words[i]);
            y = y * by + k;
        }

        if (x == y) {
            System.out.println("=");
        } else if (x < y) {
            System.out.println("<");
        } else {
            System.out.println(">");
        }
    }
}

